%% @author Administrator
%% @doc @todo Add description to account_gate.


-module(account_gate).

-include("proto.hrl").
-include("pb_account.hrl").
-include("account.hrl").

%% ====================================================================
%% API functions
%% ====================================================================
-export([handle_msg/3]).



%% ====================================================================
%% Internal functions
%% ====================================================================


handle_msg(?PROTO_MSG_LOGIN, Msg, Player) ->
	#s2c_pb_10000{uid = Uid, p_roles = PRoles} = Msg,
	Roles = [#role{role_name = Name, rid = Rid, uuid = UUid, level = Level}
			||#p_roles{name = Name, rid = Rid, uuid = UUid, level = Level}<-PRoles],
	Player1 = account_api:login(Uid, Roles, Player),
	{noreply, Player1};

handle_msg(MsgId, _Msg, Player) ->
	io:format("Unknown MsgId:~p~n",[MsgId]),
	{noreply, Player}.
